-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Store sysreg names in-line with their descriptors. #119157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This wastes some disk space, because we have to size the arrays for the maximum possible length. However, it eliminates dynamic relocations from the SysRegsList arrays.
|
To give some numbers for context here... This reduces dynamic relocations by almost 4k on Linux, just over 4% of the non-vtable relocations. It's not as big as some of the previous reductions, but that's the nature of working down the stack... The PR description says this wastes some space, so I specifically got No regression in overall size. The growth in It might be nice to use a string table and an offset, but it'd barely be better given the small size of these strings. |
|
@llvm/pr-subscribers-backend-risc-v @llvm/pr-subscribers-backend-arm Author: Owen Anderson (resistor) ChangesThis wastes some disk space, because we have to size the arrays for Full diff: https://github.com/llvm/llvm-project/pull/119157.diff 3 Files Affected:
diff --git a/llvm/lib/Target/AArch64/Utils/AArch64BaseInfo.h b/llvm/lib/Target/AArch64/Utils/AArch64BaseInfo.h
index 8f34cf054fe286..e0ccba4d6a59e8 100644
--- a/llvm/lib/Target/AArch64/Utils/AArch64BaseInfo.h
+++ b/llvm/lib/Target/AArch64/Utils/AArch64BaseInfo.h
@@ -700,8 +700,8 @@ AArch64StringToVectorLayout(StringRef LayoutStr) {
namespace AArch64SysReg {
struct SysReg {
- const char *Name;
- const char *AltName;
+ const char Name[32];
+ const char AltName[32];
unsigned Encoding;
bool Readable;
bool Writeable;
diff --git a/llvm/lib/Target/ARM/Utils/ARMBaseInfo.h b/llvm/lib/Target/ARM/Utils/ARMBaseInfo.h
index 56a925f09ea7ae..5562572c5abf48 100644
--- a/llvm/lib/Target/ARM/Utils/ARMBaseInfo.h
+++ b/llvm/lib/Target/ARM/Utils/ARMBaseInfo.h
@@ -189,7 +189,7 @@ inline static unsigned ARMCondCodeFromString(StringRef CC) {
// System Registers
namespace ARMSysReg {
struct MClassSysReg {
- const char *Name;
+ const char Name[32];
uint16_t M1Encoding12;
uint16_t M2M3Encoding8;
uint16_t Encoding;
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
index 9e36d62352ae51..fe28195654fdea 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
@@ -449,9 +449,9 @@ int getLoadFPImm(APFloat FPImm);
namespace RISCVSysReg {
struct SysReg {
- const char *Name;
- const char *AltName;
- const char *DeprecatedName;
+ const char Name[32];
+ const char AltName[32];
+ const char DeprecatedName[32];
unsigned Encoding;
// FIXME: add these additional fields when needed.
// Privilege Access: Read, Write, Read-Only.
|
|
How good is the error checking, if a future RISC-V extension adds a sysreg with a longer name? Do we need to find a place for a build-time error with a nice message? |
The error checking seems fine to me: |
|
Why not offsets into a big array of characters like we do for registers themselves? That would be more space efficient than padding all strings like this. |
I believe that is what @chandlerc was suggesting above:
I haven't had a chance to look into it yet. |
That would need new support for that kind of "searchable table" in TableGen I think. Unless we already have it? |
We do have a utility that automates building these pretty well: https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/TableGen/StringToOffsetTable.h Maybe you mean connecting it differently to something else? |
sysregs aren't a first class type in the tablegen sources. They are declared in the .td file as a GenericTable. I don't think the emitter that handles GenericTable knows how to create an array of characters. |
...
Yeah, it'd need some custom emission to wire up everything. Some of this is why I had nudged Owen -- it wasn't at all clear to me how to effectively restructure the tablegen of the backends to more systematically use offsets into a string table. Anyways... |
|
I don't see a straightforward path to moving this to a string table. I did some prototyping of attempting to move GenericTable to use string tables for all string values, but it ends up being tricky for a few reasons:
This seems like it could be an area for future enhancement if someone wants to do some major refactoring, but it's not a simple add-on improvement. |
|
Ping |
topperc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. This looks like the most straightfoward thing to do given the current tablegen capabilities.
I think we might be able to remove the barely used DeprecatedName from RISCV by adding additional rows and a IsDeprecatedName bool. I can look at that as a follow.
Local branch amd-gfx d201749 Merged main:cbf931e16f6d into amd-gfx:3d027bc4e627 Remote branch main f06756f Store sysreg names in-line with their descriptors. (llvm#119157)
This wastes some disk space, because we have to size the arrays for
the maximum possible length. However, it eliminates dynamic relocations
from the SysRegsList arrays.